package com.hly.musicbackground.Enum;

import com.hly.musicbackground.result.Code;
import lombok.Getter;

@Getter
public enum UserRootEnum {
    TOURIST(0, "游客"),
    USER(1, "普通用户"),
    ADMIN(2, "管理员"),
    ROOT(3, "超级管理员");

    private int value;
    private String str;

    UserRootEnum(int value, String str){
        this.value = value;
        this.str = str;
    }

    public static UserRootEnum findEnumByCode(int value) {
        for (UserRootEnum statusEnum : UserRootEnum.values()) {
            if (statusEnum.getValue() == value) {
                //如果需要直接返回name则更改返回类型为String,return statusEnum.name;
                return statusEnum;
            }
        }
        Code.BUSINESS_ERR("code不存在");
        return null;
    }

}
